package com.jrtc.service.impl;

import com.jrtc.base.entity.bo.*;
import com.jrtc.base.entity.vo.CatchBallRecordVo;
import com.jrtc.dao.*;
import com.jrtc.service.CatchBallRecordService;
import com.jrtc.service.QuestionNaireService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service("questionNaireService")
public class QuestionNaireServiceImpl implements QuestionNaireService {
    @Resource
    private QuestionNaireDao questionNaireDao;
    @Resource
    private QuestionDao questionDao;
    @Resource
    private AnswerDao answerDao;
    @Resource
    private StandardDao standardDao;

    /**
     * 患者问卷列表
     * */
    @Override
    public List<QuestionNaire> questionNaireList(Integer id) {
        List<QuestionNaire> questionNaireList = questionNaireDao.questionNaireList(id);
        return questionNaireList;
    }

    /**
     * 问卷详细内容
     * */
    @Override
    public QuestionNaire questionNaireDetailed(Integer id) {
        QuestionNaire questionNaire = questionNaireDao.questionNaireDetailed(id);

        List<Question> questions = questionDao.questionList(questionNaire.getId());
        if (questions != null && questions.size() > 0){
            for (Question question : questions) {
                List<Answer> answerList = answerDao.answerList(question.getId());
                if (answerList != null && answerList.size() > 0){
                    question.setAnswerList(answerList);
                }
            }
            questionNaire.setQuestionList(questions);
        }

        List<Standard> standards = standardDao.StandardList(questionNaire.getId());
        if (standards != null && standards.size() > 0){
            questionNaire.setStandardList(standards);
        }

        return questionNaire;
    }
}